package com.gopay.scheduler.job;

import com.gopay.common.constants.holiday.HolidayType;
import com.gopay.common.domain.fund.vo.FileBizParam;
import com.gopay.common.util.DateUtils;
import com.gopay.remote.cps.holiday.HolidayRemoteService;
import com.gopay.remote.fundcps.service.FileHandlerService;
import com.gopay.scheduler.GopayBaseJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 国付宝提供给监管行银行卡信息
 * @AutoGenFundBindCardInfoJob.java
 * @author baiyunpeng
 * @2016年6月16日 下午6:24:44  www.gopay.com.cn Inc.All rights reserved.
 */
public class FundBindCardFileJob extends GopayBaseJob {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Resource(name = "fileHandlerService")
    private FileHandlerService fundFileRemoteService;
    @Resource(name = "holidayRemoteService")
    private HolidayRemoteService holidayRemoteService;

    @Override
    protected void doJobInternal() {
        try {
            logger.info("国付宝提供给监管行银行卡信息（8文件）生成定时任务开始！"+ DateUtils.format(new Date()));
            String res = "";
            if(!holidayRemoteService.isHoliday(new Date(), HolidayType.FUND_COMPANY)){
                logger.info("国付宝提供给监管行银行卡信息（8文件），非基金节假日，继续执行！");
                String settleDay = DateUtils.format(new Date(), "yyyyMMdd");
                res = fundFileRemoteService.superviseBindCardFile(new FileBizParam(settleDay,null));
            }else{
                logger.info("国付宝提供给监管行银行卡信息（8文件），基金节假日,不执行逻辑！");
            }
            logger.info("国付宝提供给监管行银行卡信息（8文件）生成定时任务结束："+res);
        } catch (Exception e) {
            logger.error("国付宝提供给监管行银行卡信息（8文件）生成定时任务异常"+e.getMessage(),e);
        }
    }
}
